ostree admin instutil: make --help work for subcommands
authorOwen W. Taylor <otaylor@fishsoup.net>
Wed, 24 Sep 2014 13:23:56 +0000 (09:23 -0400)
committerOwen W. Taylor <otaylor@fishsoup.net>
Thu, 25 Sep 2014 07:08:06 +0000 (03:08 -0400)
Even though the subcommands don't take arguments, use a GOptionContext
so that --help works as expected.

https://bugzilla.gnome.org/show_bug.cgi?id=737194

src/ostree/ot-admin-instutil-builtin-selinux-ensure-labeled.c
src/ostree/ot-admin-instutil-builtin-set-kargs.c

index 2ffe098162fd88e628c7bcebb051364de856cf30..8bd0c8a1aa27a64a92c3c704239d0679b3a95e37 100644 (file)
@@ -173,6 +173,10 @@ selinux_relabel_dir (OstreeSePolicy                *sepolicy,
   return ret;
 }
 
+static GOptionEntry options[] = {
+  { NULL }
+};
+
 gboolean
 ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
@@ -183,8 +187,16 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeS
   gs_unref_object OstreeSePolicy *sepolicy = NULL;
   gs_unref_ptrarray GPtrArray *deployments = NULL;
   OstreeDeployment *first_deployment;
+  GOptionContext *context = NULL;
   gs_unref_object GFile *deployment_path = NULL;
 
+  context = g_option_context_new ("[SUBPATH PREFIX] - relabel all or part of a deployment");
+
+  g_option_context_add_main_entries (context, options, NULL);
+
+  if (!g_option_context_parse (context, &argc, &argv, error))
+    goto out;
+
   if (!ostree_sysroot_load (sysroot, cancellable, error))
     goto out;
 
@@ -227,5 +239,7 @@ ot_admin_instutil_builtin_selinux_ensure_labeled (int argc, char **argv, OstreeS
 
   ret = TRUE;
  out:
+  if (context)
+    g_option_context_free (context);
   return ret;
 }
index 5ca4021247fb41ee86e6f6e3c74b2451b91c2d93..6264a04e3ecf159d175586f73348431a03bcc134 100644 (file)
 
 #include "otutil.h"
 
+static GOptionEntry options[] = {
+  { NULL }
+};
+
 gboolean
 ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeSysroot *sysroot, GCancellable *cancellable, GError **error)
 {
@@ -34,8 +38,16 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeSysroot *sysro
   guint i;
   gs_unref_ptrarray GPtrArray *deployments = NULL;
   OstreeDeployment *first_deployment = NULL;
+  GOptionContext *context = NULL;
   gs_unref_ptrarray GPtrArray *new_kargs = NULL;
 
+  context = g_option_context_new ("ARGS - set new kernel command line arguments");
+
+  g_option_context_add_main_entries (context, options, NULL);
+
+  if (!g_option_context_parse (context, &argc, &argv, error))
+    goto out;
+
   if (!ostree_sysroot_load (sysroot, cancellable, error))
     goto out;
 
@@ -60,5 +72,7 @@ ot_admin_instutil_builtin_set_kargs (int argc, char **argv, OstreeSysroot *sysro
 
   ret = TRUE;
  out:
+  if (context)
+    g_option_context_free (context);
   return ret;
 }